﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Model
{
    public class ActivityJoinRequestRepository
    {
        private JzSportDbContext _dbContext;

        public ActivityJoinRequestRepository(JzSportDbContext dbContext)
        {
            _dbContext = dbContext;
        }

        public void Create(ActivityJoinRequest entity)
        {
            _dbContext.Set<ActivityJoinRequest>().Add(entity);
        }

        public ActivityJoinRequest Get(Guid activityId, int userId)
        {
            return _dbContext.Set<ActivityJoinRequest>().Where(p => p.ActivityId == activityId && p.UserId == userId)
                .SingleOrDefault();
        }

        public void Delete(ActivityJoinRequest entity)
        {
            _dbContext.Entry<ActivityJoinRequest>(entity).State = System.Data.EntityState.Deleted;
        }
    }
}
